//
//  FSDisCoverCellTableViewCell.m
//  fanshu
//
//  Created by mh on 16/3/28.
//  Copyright © 2016年 FS. All rights reserved.
//

#import "FSDisCoverArticleCell.h"
#import "FSDisCoverFrameModel.h"


@implementation FSDisCoverArticleCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initWithSubViews];
        
    }
    return self;
}

- (void)initWithSubViews{
    //头像
    UIImageView *iconView = [[UIImageView alloc] init];
    [self.contentView addSubview:iconView];
    self.iconView = iconView;
    //名称  120  166  194
    UILabel *name = [[UILabel alloc] init];
    name.textColor = colorOfText(120, 166, 194);
    name.font = nameFont;
    [self.contentView addSubview:name];
    self.name = name;
    //发布时间  205  205  205
    UILabel *time = [[UILabel alloc] init];
    time.textColor = colorOfText(205, 205, 205);
    time.font = timeFont;
    [self.contentView addSubview:time];
    self.time = time;
    //标题
    UILabel *title = [[UILabel alloc] init];
    title.font = titleFont;
    title.numberOfLines = 0;
    [self.contentView addSubview:title];
    self.title = title;
    //配图
    UIImageView *image = [[UIImageView alloc] init];
    [self.contentView addSubview:image];
    self.image = image;
    //类型 203 153 145
    UIButton *type = [[UIButton alloc] init];
    [type setTitleColor:colorOfText(203, 153, 145) forState:UIControlStateNormal];
    type.layer.borderColor = [UIColor orangeColor].CGColor;
    type.layer.borderWidth = 1.5;
    type.layer.masksToBounds = YES;
    type.layer.cornerRadius = 10;
    type.titleLabel.font = typeFont;
    [self.contentView addSubview:type];
    self.type = type;
    //阅读数214 177 115
    UILabel *countOfRead = [[UILabel alloc] init];
    countOfRead.textColor = colorOfText(214, 177, 115);
    countOfRead.font = countOfReadFont;
    [self.contentView addSubview:countOfRead];
    self.countOfRead = countOfRead;
    //评论数
    UILabel *countOfComment = [[UILabel alloc] init];
    countOfComment.textColor = colorOfText(213, 177, 115);
    countOfComment.font = countOfCommentFont;
    [self.contentView addSubview:countOfComment];
    self.countOfComment = countOfComment;
    //喜欢数
    UILabel *countOfLike = [[UILabel alloc] init];
    countOfLike.textColor = colorOfText(213, 177, 115);
    countOfLike.font = countOfLikeFont;
    [self.contentView addSubview:countOfLike];
    self.countOfLike = countOfLike;
}

- (void)setFrameModel:(FSDisCoverFrameModel *)frameModel{
    _frameModel = frameModel;
    FSDiscoverArticleModel *model = frameModel.model;
    //头像
    self.iconView.image = [UIImage imageNamed:model.icon];
    //名称
    self.name.text = model.name;
    //发布时间   需要自定义
    self.time.text = model.time;
    //标题
    self.title.text = model.title;
    //配图 不一定有配图
    if (model.image) self.image.image = [UIImage imageNamed:model.image];
    //类型
    [self.type setTitle:model.type forState:UIControlStateNormal];
    //阅读数
    self.countOfRead.text = [NSString stringWithFormat:@"阅读:%@",model.countOfRead];
    //评论数
    self.countOfComment.text = [NSString stringWithFormat:@"评论:%@",model.countOfComment];
    //喜欢数
    self.countOfLike.text = [NSString stringWithFormat:@"喜欢:%@",model.countOfLike];

}

- (void)layoutSubviews{
    [super layoutSubviews];
    self.iconView.frame = self.frameModel.iconF;
    self.name.frame = self.frameModel.nameF;
    self.time.frame = self.frameModel.timeF;
    self.title.frame = self.frameModel.titleF;
    self.image.frame = self.frameModel.imageF;
    self.type.frame = self.frameModel.typeF;
    self.countOfRead.frame = self.frameModel.countOfReadF;
    self.countOfComment.frame = self.frameModel.countOfCommentF;
    self.countOfLike.frame = self.frameModel.countOfLikeF;
}

@end
